<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>车辆基础资料</title>
<link href="<%=path%>/CSS/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
<script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
	<%@ include file="/WEB-INF/JSP/ajax.jsp"%>
<script type="text/javascript">

 /* function submit(deleteId){
	  $(".sure").click(function(){
	  $(".tip").fadeOut(100);
	  location='deleteCarByFid?deleteId='+deleteId+'';
	  })
	  
	  $(".cancel").click(function(){
		  $(".tip").fadeOut(100);
		});

	  } 
 $(document).ready(function(){

	 $(".tablelink").click(function(){
		  $(".tip").fadeIn(200);
	 });
		  
	$(".tiptop a").click(function(){
		  $(".tip").fadeOut(200);
	});

	  
	  $("#addCar").click(function(){
	   location="insertCar";
	   });
	   
	}); */
 
</script>
<style type="text/css">
.seachform li label{line-height: 45px;color: #444444}
.scinput{line-height: 10px;margin-top: 5px}
.scinput1{margin-top: 5px;height: 30px;}
.scbtn{background: #57a0ff;border-radius:20px;width: 110px;margin-top: 4px;height: 35px}
.scbtn2{height: 20px;background: #57a0ff;border-radius:20px;width: 50px;color: #fff;display: none;}

.tablelist th{background: none;border-bottom: none;}
thead {background: #f2f2f2}
tbody tr:nth-child(even) {background: #f7f8fd}
.tablelist th{height: 45px;padding-left: 30px}
.tablelist td{border-right:none;padding-left: 30px;border-bottom: 1px solid #c7c7c7;}
tbody tr{height: 38px}
.check{padding-left: 0px}
a{cursor: pointer;}
.detail{cursor: pointer;color: #056dae}
.detail:HOVER {
	color: #57a0ff
}
.deldetail{cursor: pointer;color: #056dae}
.deldetail:HOVER{cursor: pointer;color: #056dae}
</style>
</head>
<body style="background: #f5f5f5;padding: 0 10px;">
<div id="location_top">
		<div class="place" style="background: #f5f5f5;margin-top: 10px">
			<ul class="placeul">
				<li><a href="#">学员管理</a></li>
				<li><a href="#">科目一技能交接</a></li>
			</ul>
		</div>
	
		<div class="rightinfo" style="background: #fff;border-radius:10px;height: 45px;">

			<form action="<%=path%>/DrivingSys/selSkillByCon" method="post">
				<ul class="seachform">
					    <li><label>学员名称</label><input name="cfstudentName" type="text" class="scinput" value="${skillEntry1.cfstudentName}"/></li>
					    <li><label>身份证号码</label><input name="cfidcardno" type="text" class="scinput" value="${skillEntry1.cfidcardno}"/></li>
					    <li><label>单据编号</label><input name="fnumber" type="text" class="scinput" value="${skill1.fnumber}"/></li>
					    <li><label>业务开始时间</label><input class="scinput1"  name="beginTime" type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}',dateFmt:'yyyy-MM-dd'})" 
					    id="datemin" class="input-text Wdate" style="width:150px;" value="${beginTime}"></li>
						<li><label>业务结束时间</label><input class="scinput1"  name="endTime" type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',dateFmt:'yyyy-MM-dd'})"
						id="datemax" class="input-text Wdate" style="width:150px;"value="${endTime}"></li>		
						<li><label>&nbsp;</label><input name="" type="submit"  style="outline: none;" class="scbtn" value="立即查询" /></li>
				</ul>
			</form>
		</div>
</div>
<div id="data_table_new"
	 style="margin-bottom: 0px;margin-top: 30px;background: #fff;border-radius:10px;box-shadow: 0 0 10px #f2f2f2;">
			<ul>
				 <li style="height: 40px;text-align: left;color: #999999;">
				  <span style="font-size: 12px;">
				  <shiro:hasPermission name="/addSkill">
				  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;" src="<%=path%>/images/list/xz.png">
				       &nbsp;<a href="<%=path%>/DrivingSys/addSkill">新增</a>
				  </shiro:hasPermission>
					  <shiro:hasPermission name="/delSkillById">
				  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;" src="<%=path%>/images/list/sc.png">
				       &nbsp;<a class="del">删除</a>
					  </shiro:hasPermission>
					  <shiro:hasPermission name="/selSkillById">
				  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;" src="<%=path%>/images/list/xg.png">
				       &nbsp;<a class="update">修改</a>
					  </shiro:hasPermission>
					   <shiro:hasPermission name="/outSkillExcel">
						  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;width: 14px" src="<%=path%>/images/list/excel.png">
						  &nbsp;<a class="outExcel">导出Excle</a>
					   </shiro:hasPermission>
					  <shiro:hasPermission name="/outChangeClazzExcel">
						  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;width: 14px" src="<%=path%>/images/list/excel.png">
						  &nbsp;<a class="checkProcess">查看流程图</a>
					  </shiro:hasPermission>
				  </span>
				  
				 </li>
			</ul>
	<table class="tablelist" id="content" style="white-space:nowrap;">
			<thead>
				<tr style="position: static;">
					<th><input type="checkbox" class="check"  /></th>
					<th>单据编号</th>
					<th>业务日期</th>
					<th>备注</th>
					<th>审核人名称</th>
					<th>制单人名称</th>
					<th>学员</th>
					<th>学员编码</th>
					<th>身份证号码</th>
					<th>备注</th>
					<th>单据状态</th>
					<th>性别</th>
					<th>车型</th>
					<th>手机</th>
					<th>班级</th>
					<th>操作</th>
				</tr>
			</thead>
			<c:forEach items="${skills}" var="skill" varStatus="s">
			<tbody class="item">
				<tr class="skill" id="${skill.fnumber}">
					<td class="fnumber" ><input type="checkbox"  value="${skill.fid}" name="check"/></td>
					<td class="fnumber" id="fnumber" >${skill.fnumber}</td>
					<td class="fnumber" >${skill.fbizdate}</td>
					<td class="fnumber" >${skill.fdescription}</td>
					<td class="fnumber" >${skill.fauditorName}</td>
					<td class="fnumber" style="border-right: 1px solid #c7c7c7" id="end">${skill.fhandlerName}</td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<c:if test="${skill.cfbillstate eq 5}">
					<td class="state">审核</td>
					</c:if>
					<c:if test="${skill.cfbillstate eq 4}">
					<td class="state">提交</td>
					</c:if>
					<c:if test="${skill.cfbillstate eq 3}">
					<td class="state">保存</td>
					</c:if>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td class="fnumber">
					   <img alt="" height="11px" src="<%=path%>/images/list/xg.png">
						<a href="<%=path%>/DrivingSys/selSkillById?fid=${skill.fid}" class="tablelink">查看</a>&nbsp;&nbsp;&nbsp;
						&nbsp;&nbsp;&nbsp;<img alt="" height="11px" src="<%=path%>/images/list/sc.png">
						<a onclick="delStudent('${skill.fid}',this)" class="tablelink">删除</a>&nbsp;&nbsp;&nbsp;
				    </td>
				</tr>
				</tbody>
				<tfoot></tfoot>
			</c:forEach>
		<%--		rhc  信息总条数--%>
		<tr class="sq">
			<td>合计:</td>
			<td>${messageAmount}</td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
		</table>
		</div>
<div id="location_bottom">
		<pg:pager items="${pb.tr}" url="${pb.url}" export="offset,currentPageNumber=pageNumber" maxPageItems="${pb.ps}">  
			   <pg:param name="cfstudentName" value="${skillEntry1.cfstudentName}"/>
    		   <pg:param name="fnumber" value="${skill1.fnumber}"/>
    		   <pg:param name="cfidcardno" value="${skillEntry1.cfidcardno}"/>
    		   <pg:param name="beginTime" value="${beginTime}"/> 
    		   <pg:param name="endTime" value="${endTime}"/>   
            <pg:index>  
               <pg:first>
               <a href="${pageUrl}&&type=${type}" >
               <nobr>
               [首页]
               </nobr>
              </a>   
               </pg:first>  
               <pg:prev><a href="${pageUrl}&&type=${type}">前一页</a></pg:prev>  
               <pg:pages>  
                     <c:choose>  
                        <c:when test="${currentPageNumber eq pageNumber}">    
                           <font color="red">${pageNumber }</font>  
                        </c:when>    
                        <c:otherwise>    
                           <a href="${pageUrl}&&type=${type}">${pageNumber}</a>   
                        </c:otherwise>    
                     </c:choose>  
               </pg:pages>  
               <pg:next><a href="${pageUrl}&&type=${type}">下一页</a></pg:next>  
               <pg:last><a href="${pageUrl}&&type=${type}"><nobr>[尾页]</nobr></a></pg:last>  
            </pg:index>      
         </pg:pager>
</div>
		<div class="tip">
			<div class="tiptop">
                <span>提示信息</span>
			</div>
			<div class="tipinfo">
				<span><img src="<%=path%>/images/ticon.png" /></span>
				<div class="tipright">
					<p>是否确认对信息删除 ？</p>
					<cite>如果是请点击确定按钮 ，否则请点取消。</cite>
				</div>
			</div>
			<div class="tipbtn">
				<input name="" type="button" class="sure" value="确定" />&nbsp; <input
					name="" type="button" class="cancel" value="取消" />
			</div>
		</div>
</body>
<script type="text/javascript" src="<%=path%>/JS/tempJs/tool.js"></script>
<script type="text/javascript">

    // $(function () {
    //     $(".tip").css("left",$(".tablelist").width()-600)
    // })

	$(document).ready(function(){


        var type = "${type}";
        if (type == '0' || type == '' || type == null) {

        } else {
            //alert("添加成功");
            editAlert();
        }


        function mwEvent(event)
		{
		    if(event.wheelDelta<=0 || event.detail>0)
		        this.scrollTop += 5;
		    else
		        this.scrollTop -= 5;
		}



		$('.skill').each(function(i){
		 var fid=$(this).find('input[type=checkbox]').val()
		 var obj=$(this)
		 var page=6
		 var state=$(this).find('.state').text()
		 var fnumber=$(this).find('#fnumber').html()
			if(i == 0){
                var flag = 0;
			}else {
		      var flag = 1
			}
		 $.ajax({
			    url:'<%=path%>/DrivingSys/selSkillEntryByFid',
			    type: "post",
			    data:{'fid':fid},
			    dataType:"json",
			    success: function(json) {

			    	if(json.length > 5){
			    		if(json[0].cfsex==1){
		    				  var	str="男"
		    				}else if(json[0].cfsex==2){
		    					var str="女"
		    				}else{
		    					var str=""
		    				}
			    		if(json[0].cfdesc == null){
			    			obj.find('#end').next().next().next().next().text()
			    		}else{
			    			obj.find('#end').next().next().next().next().text(json[0].cfdesc)
			    		}
				    		obj.find('#end').next().text(json[0].cfstudentName)
				    		obj.find('#end').next().next().text(json[0].cfstudentno)
				    		obj.find('#end').next().next().next().text(json[0].cfidcardno)
				    		obj.find('#end').next().next().next().next().next().next().text(str)
				    		obj.find('#end').next().next().next().next().next().next().next().text(json[0].cfcx)
				    		obj.find('#end').next().next().next().next().next().next().next().next().text(json[0].cfphone)
				    		obj.find('#end').next().next().next().next().next().next().next().next().next().text(json[0].cfclazz)
				    		var  str1=''
				    		for(var i=1;i<5;i++){
				    			str1+="<tr><td>"+json[i].cfstudentName+"</td><td>"+json[i].cfstudentno+"</td>"
				    			str1+="<td>"+json[i].cfidcardno+"</td>"
				    			if(json[i].cfdesc == null || json[i].cfdesc == 'undefined'){
			    					str1+="<td></td>"
			    				}else{
			    					str1+="<td>"+json[i].cfdesc+"</td>"
			    				}
				    			str1+="<td class='state'>"+state+"</td>"
				    				if(json[i].cfsex==1){
				    					str1+="<td>男</td>"
				    				}else if(json[i].cfsex==2){
				    					str1+="<td>女</td>"
				    				}else{
				    					str1+="<td></td>"
				    				}

				    			str1+="<td>"+json[i].cfcx+"</td><td>"+json[i].cfphone+"</td>"
				    			str1+="<td>"+json[i].cfclazz+"</td></tr>"
				    		}
				    		str1+=' <tr   class="detail"> <td>查看详情</td> <td></td> <td ><input class="fid" type="hidden"  value="'+fid+'" /> <input id="fnumber1" type="hidden"  value="'+fnumber+'" /> </td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr>'
				    		obj.after(str1)
				    		obj.find('.fnumber').attr('rowspan',page)

			    	}else if(json.length == 1){
			    		if(json[0].cfsex==1){
		    				  var	str="男"
		    				}else if(json[0].cfsex==2){
		    					var str="女"
		    				}else{
		    					var str=""
		    				}
			    		if(json[0].cfdesc == null){
			    			obj.find('#end').next().next().next().next().text()
			    		}else{
			    			obj.find('#end').next().next().next().next().text(json[0].cfdesc)
			    		}
				    		obj.find('#end').next().text(json[0].cfstudentName)
				    		obj.find('#end').next().next().text(json[0].cfstudentno)
				    		obj.find('#end').next().next().next().text(json[0].cfidcardno)
				    		obj.find('#end').next().next().next().next().next().next().text(str)
				    		obj.find('#end').next().next().next().next().next().next().next().text(json[0].cfcx)
				    		obj.find('#end').next().next().next().next().next().next().next().next().text(json[0].cfphone)
				    		obj.find('#end').next().next().next().next().next().next().next().next().next().text(json[0].cfclazz)
			    	}else{

			    		if(json[0].cfsex==1){
		    				  var	str="男"
		    				}else if(json[0].cfsex==2){
		    					var str="女"
		    				}else{
		    					var str=""
		    				}
			    		if(json[0].cfdesc == null){
			    			obj.find('#end').next().next().next().next().text()
			    		}else{
			    			obj.find('#end').next().next().next().next().text(json[0].cfdesc)
			    		}
				    		obj.find('#end').next().text(json[0].cfstudentName)
				    		obj.find('#end').next().next().text(json[0].cfstudentno)
				    		obj.find('#end').next().next().next().text(json[0].cfidcardno)
				    		obj.find('#end').next().next().next().next().next().next().text(str)
				    		obj.find('#end').next().next().next().next().next().next().next().text(json[0].cfcx)
				    		obj.find('#end').next().next().next().next().next().next().next().next().text(json[0].cfphone)
				    		obj.find('#end').next().next().next().next().next().next().next().next().next().text(json[0].cfclazz)
				    		var  str1=''
				    		for(var i=1;i<json.length;i++){
				    			str1+="<tr><td>"+json[i].cfstudentName+"</td><td>"+json[i].cfstudentno+"</td>"
				    			str1+="<td>"+json[i].cfidcardno+"</td>"
				    			if(json[i].cfdesc == null || json[i].cfdesc == 'undefined'){
			    					str1+="<td></td>"
			    				}else{
			    					str1+="<td>"+json[i].cfdesc+"</td>"
			    				}
				    			str1+="<td>"+state+"</td>"
				    				if(json[i].cfsex==1){
				    					str1+="<td>男</td>"
				    				}else if(json[i].cfsex==2){
				    					str1+="<td>女</td>"
				    				}else{
				    					str1+="<td></td>"
				    				}

				    			str1+="<td>"+json[i].cfcx+"</td><td>"+json[i].cfphone+"</td>"
				    			str1+="<td>"+json[i].cfclazz+"</td></tr>"
				    		}

				    		obj.after(str1)
				    		obj.find('.fnumber').attr('rowspan',json.length)
			    	}
					if(flag == 0) {
                        $(".tablelist").width($(".tablelist").width()+ 60)
                        fixation_List()
					}

				},
				error: function(){alert('Error');}
	 			});

		})

        /*$('input:checkbox:not(":first")').each(function(i){
            if($(this).parent().parent().find('td:nth-child(11)').html() == '审核' || $(this).parent().parent().find('td:nth-child(11)').html() == '提交' ) {
                $(this).attr('disabled', true)
            }
        })*/

		$('.detail').live('click',function(){
			var obj = $(this)
			var fid = $(this).find('.fid').val()
			var state = $(this).prev().find('.state').text()
			var fnumber = $(this).find('#fnumber1').val()
			$.ajax({
			    url:'<%=path%>/DrivingSys/selSkillEntryByFid',
			    type: "post",
			    data:{'fid':fid},
			    dataType:"json",
			    success: function(json) {
			    		var  str1=''
			    		for(var i=5;i<json.length;i++){
			    			str1+="<tr><td>"+json[i].cfstudentName+"</td><td>"+json[i].cfstudentno+"</td>"
			    			str1+="<td>"+json[i].cfidcardno+"</td>"
			    			if(json[i].cfdesc == null || json[i].cfdesc == 'undefined'){
		    					str1+="<td></td>"
		    				}else{
		    					str1+="<td>"+json[i].cfdesc+"</td>"
		    				}
			    			str1+="<td>"+state+"</td>"
			    				if(json[i].cfsex==1){
			    					str1+="<td>男</td>"
			    				}else if(json[i].cfsex==2){
			    					str1+="<td>女</td>"
			    				}else{
			    					str1+="<td></td>"
			    				}

			    			str1+="<td>"+json[i].cfcx+"</td><td>"+json[i].cfphone+"</td>"
			    			str1+="<td>"+json[i].cfclazz+"</td></tr>"
			    		}
			    		str1+=' <tr   class="deldetail"> <td>收起详情</td> <td></td> <td ><input class="fid" type="hidden"  value="'+fid+'" /> <input id="fnumber1" type="hidden"  value="'+fnumber+'" /> </td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr>'
			    		/* obj.remove() */
			    		obj.before(str1)
			    		$('#'+fnumber+'').find('.fnumber').attr('rowspan',json.length+1)
			    		obj.remove()
			    },
			    error:function(){
			    	alert("error")
			    }
		})
		})



		$('.deldetail').live('click',function(){
			var fid = $(this).find('.fid').val()
			var fnumber = $(this).find('#fnumber1').val()
			var page = 6
			var fnumber = $(this).find('#fnumber1').val()
				$('#'+fnumber+'').find('.fnumber').attr('rowspan',page)
				$('#'+fnumber+'').next().next().next().next().nextAll().remove()
			var	str1=' <tr   class="detail"> <td>查看详情</td> <td></td> <td ><input class="fid" type="hidden"  value="'+fid+'" /> <input id="fnumber1" type="hidden"  value="'+fnumber+'" /> </td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr>'
				$('#'+fnumber+'').parent().append(str1)

		})






		$('.del').click(function(){
            var spCodesTemp = "";
            var flag = 0
            $('[name=check]:checked').each(function(i){
                if($(this).parent().parent().find('td:nth-child(11)').html() == '审核' || $(this).parent().parent().find('td:nth-child(11)').html() == '提交' ){
                    flag=1
                    $(this).attr('checked',false)
                }else {
                    if(0==i){
                        spCodesTemp = $(this).val();
                    }else{
                        spCodesTemp += (","+$(this).val());
                    }
                }
            });

            if(flag == 1){
                alert("提交或审核状态不能被删除")
            }else if(spCodesTemp==""){
                alert("请选择单据")
            }else{
                $(".tip").fadeIn(100);
                $(".sure").click(function(){
                    location.href='<%=path%>/DrivingSys/delSkillById?fid='+spCodesTemp
                    $(".tip").fadeOut(100);
                })
            }

            $(".cancel").click(function(){
                $(".tip").fadeOut(100);
            });


		})

		$('.skill').live('dblclick',function(){
		 var fid=$(this).find('input:checkbox').val()
		 fid=fid.replace(/\+/g,"%2B");
		 location.href='<%=path%>/DrivingSys/selSkillById?fid='+fid
		})

        $(".checkProcess").live('click',function(){
            var spCodesTemp = "";
            $('[name=check]:checked').each(function(i){
                if(0==i){
                    spCodesTemp = $(this).parent().next().text();
                }else{
                    spCodesTemp += (","+$(this).parent().next().text());
                }
            });
            if(spCodesTemp==""){
                alert("请选择单据")
            }else{
                var fnumber=spCodesTemp.split(",")[0]
                fnumber=fnumber.replace(/\+/g,"%2B");
                lookActivitiImg('${ActivitiKey}',fnumber)
            }

        })

		$('.update').click(function(){
			var spCodesTemp = "";
            $('[name=check]:checked').each(function(i){
		       if(0==i){
		        spCodesTemp = $(this).val();
		       }else{
		        spCodesTemp += (","+$(this).val());
		       }
		      });
		      if(spCodesTemp==""){
		    	  alert("请选择学员")
		      }else{
		      var fid=spCodesTemp.split(",")[0]
		      		fid=fid.replace(/\+/g,"%2B");
		      location.href='<%=path%>/DrivingSys/selSkillById?fid='+fid
		      }
		})
        /* 全选功选 */
        $('.check').click(function(){
            if($(this).attr("checked")){
                $('input:checkbox:not(":first")').each(function() {
                    if(typeof($(this).attr('disabled')) == 'undefined'){
                        $(this).prop("checked", true)
                    }
                })
            }else{
                $('input:checkbox').removeAttr('checked')
            }
        })
			})


    function delStudent(deleteId,_this){
        var $this = $(_this)
        if($this.parent().parent().find('td:nth-child(11)').html() == '审核' || $this.parent().parent().find('td:nth-child(11)').html() == '提交'){
            alert($this.parent().parent().find('td:nth-child(11)').html()+'状态不能删除')
            return false
        } else {
            $(".tip").animate(({top: $(window).scrollTop()+250}))
            $(".tip").fadeIn(200);
            $('.window-mask').fadeToggle()
            $(".sure").click(function () {
                $('.window-mask').fadeOut()
                $(".tip").fadeOut(100);
                fid=deleteId.replace(/\+/g,"%2B");
                location='<%=path%>/DrivingSys/delSkillById?fid='+fid+'';

            })
        }
        $(".cancel").click(function(){
            $('.window-mask').fadeOut()
            $(".tip").fadeOut(100);
        });

    }

    $('.outExcel').live('click',function () {
        var cfstudentName = $('.seachform').find('input[name=cfstudentName]').val()
        var fnumber = $('.seachform').find('input[name=fnumber]').val()
        var cfidcardno = $('.seachform').find('input[name=cfidcardno]').val()
        var beginTime = $('.seachform').find('input[name=beginTime]').val()
        var endTime = $('.seachform').find('input[name=endTime]').val()
        location = '<%=path%>/DrivingSys/outSkillExcel?cfstudentName='+ cfstudentName + '&cfidcardno=' + cfidcardno + '&fnumber=' + fnumber + '&beginTime=' + beginTime + '&endTime=' + endTime
    })
</script>
</html>